import java.util.ArrayList;
import java.util.List;

abstract class Component {

    public String Name;

    public Component(String name) {
        this.Name = name;
    }

    public abstract void add(Component c);

    public abstract void remove(Component c);

    public void show(int level) {
        String prefix = "";
        for (int i = 0; i < level; i++) {
            prefix += "-";
        }
        System.out.println((prefix + Name));
    }
}

public class Composite extends Component {

    public static void main(String[] args) {
        Component root = new Composite("root");
        Component nodeA = new Composite("nodeA");
        Component nodeB = new Composite("nodeB");
        Component leafA = new Leaf("leafA");
        Component leafB = new Leaf("leafB");
        root.add(nodeA);
        root.add(nodeB);
        nodeA.add(leafA);
        nodeA.add(leafB);
        nodeB.add(leafA);
        nodeB.add(leafB);
        nodeA.remove(leafA);
        root.show(1);
    }

    public Composite(String name) {
        super(name);
    }

    List<Component> components = new ArrayList<Component>();

    @Override
    public void add(Component c) {
        this.components.add(c);
    }

    @Override
    public void remove(Component c) {
        this.components.remove(c);
    }

    @Override
    public void show(int level) {
        super.show(level);
        for (Component component : components) {
            component.show(level + 1);
        }
    }
}

class Leaf extends Component {
    public Leaf(String name) {
        super(name);
    }

    @Override
    public void add(Component c) {
    }

    @Override
    public void remove(Component c) {
    }
}